package cn.lg.soar.database.handler.type;

import cn.lg.soar.core.util.InnerSerializeUtils;
import cn.lg.soar.database.base.model.FileInfo;
import com.baomidou.mybatisplus.extension.handlers.AbstractJsonTypeHandler;
import org.apache.ibatis.type.JdbcType;
import org.apache.ibatis.type.MappedJdbcTypes;
import org.apache.ibatis.type.MappedTypes;

/**
 * FileInfo 类型处理器
 * @author luguoxiang
 * @date 2022-05-20
 * 开源项目：https://gitee.com/lgx1992/lg-soar 求star！请给我star！请帮我点个star！
 */
@MappedJdbcTypes(JdbcType.VARCHAR)
@MappedTypes(FileInfo.class)
public class FileInfoTypeHandler extends AbstractJsonTypeHandler<FileInfo> {

    public FileInfoTypeHandler() {
        super(FileInfo.class);
    }

    @Override
    public FileInfo parse(String json) {
        return InnerSerializeUtils.parseObject(json, FileInfo.class);
    }

    @Override
    public String toJson(FileInfo obj) {
        return InnerSerializeUtils.toJson(obj);
    }

}
